﻿using System;
using Character;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x020001D2 RID: 466
public class AcceCopyHelperUI : MonoBehaviour
{
	// Token: 0x06000C2C RID: 3116 RVA: 0x00046EDC File Offset: 0x000450DC
	public void SetHuman(Human human)
	{
		this.human = human;
		this.SetAccessoryNames();
	}

	// Token: 0x06000C2D RID: 3117 RVA: 0x00046EEC File Offset: 0x000450EC
	private void OnEnable()
	{
		this.SetAccessoryNames();
	}

	// Token: 0x06000C2E RID: 3118 RVA: 0x00046EF4 File Offset: 0x000450F4
	public void SetAccessoryNames()
	{
		if (this.human == null)
		{
			return;
		}
		for (int i = 0; i < 10; i++)
		{
			AccessoryData accessoryData = this.human.accessories.GetAccessoryData(this.human.customParam.acce, i);
			string text = (i + 1).ToString("00:");
			if (accessoryData != null)
			{
				text += accessoryData.name;
			}
			else
			{
				text += "なし";
			}
			this.dstSlots[i].GetComponentInChildren<Text>().text = text;
			this.srcSlots[i].GetComponentInChildren<Text>().text = text;
		}
	}

	// Token: 0x06000C2F RID: 3119 RVA: 0x00046FA4 File Offset: 0x000451A4
	private void Update()
	{
		int num;
		int num2;
		this.CheckToggles(out num, out num2);
		AccessoryData accessoryData = (num2 < 0) ? null : this.human.accessories.GetAccessoryData(this.human.customParam.acce, num2);
		AccessoryData accessoryData2 = (num < 0) ? null : this.human.accessories.GetAccessoryData(this.human.customParam.acce, num);
		bool interactable = num != -1 && num2 != -1 && (accessoryData != null || accessoryData2 != null);
		bool interactable2 = accessoryData != null && accessoryData2 != null;
		this.buttons_slotCopy.interactable = interactable;
		this.buttons_posCopy.interactable = interactable2;
		this.buttons_posCopyRevH.interactable = interactable2;
		this.buttons_posCopyRevV.interactable = interactable2;
	}

	// Token: 0x06000C30 RID: 3120 RVA: 0x00047084 File Offset: 0x00045284
	private void CheckToggles(out int dst, out int src)
	{
		dst = -1;
		src = -1;
		for (int i = 0; i < 10; i++)
		{
			if (this.dstSlots[i].isOn)
			{
				dst = i;
			}
			if (this.srcSlots[i].isOn)
			{
				src = i;
			}
		}
	}

	// Token: 0x06000C31 RID: 3121 RVA: 0x000470D4 File Offset: 0x000452D4
	public void Button_CopySlot()
	{
		AccessoryParameter acce = this.human.customParam.acce;
		int num;
		int num2;
		this.CheckToggles(out num, out num2);
		acce.slot[num].Copy(acce.slot[num2]);
		if (this.reverse.isOn)
		{
			acce.slot[num].nowAttach = Accessories.GetReverseAttach(acce.slot[num].nowAttach);
		}
		this.human.accessories.AccessoryInstantiate(acce, num, false, null);
		Resources.UnloadUnusedAssets();
		this.SetAccessoryNames();
		SystemSE.Play(SystemSE.SE.YES);
		this.Update_OtherUI();
	}

	// Token: 0x06000C32 RID: 3122 RVA: 0x0004716C File Offset: 0x0004536C
	public void Button_CopyPos()
	{
		AccessoryParameter acce = this.human.customParam.acce;
		int num;
		int num2;
		this.CheckToggles(out num, out num2);
		acce.slot[num].addPos = acce.slot[num2].addPos;
		acce.slot[num].addRot = acce.slot[num2].addRot;
		acce.slot[num].addScl = acce.slot[num2].addScl;
		this.human.accessories.UpdatePosition(acce, num);
		SystemSE.Play(SystemSE.SE.YES);
		this.Update_OtherUI();
	}

	// Token: 0x06000C33 RID: 3123 RVA: 0x00047200 File Offset: 0x00045400
	public void Button_CopyPosRev_H()
	{
		AccessoryParameter acce = this.human.customParam.acce;
		int num;
		int num2;
		this.CheckToggles(out num, out num2);
		acce.slot[num].addPos = acce.slot[num2].addPos;
		acce.slot[num].addRot = acce.slot[num2].addRot;
		acce.slot[num].addScl = acce.slot[num2].addScl;
		acce.slot[num].addRot.y = Mathf.DeltaAngle(0f, acce.slot[num].addRot.y + 180f);
		this.human.accessories.UpdatePosition(acce, num);
		SystemSE.Play(SystemSE.SE.YES);
		this.Update_OtherUI();
	}

	// Token: 0x06000C34 RID: 3124 RVA: 0x000472C8 File Offset: 0x000454C8
	public void Button_CopyPosRev_V()
	{
		AccessoryParameter acce = this.human.customParam.acce;
		int num;
		int num2;
		this.CheckToggles(out num, out num2);
		acce.slot[num].addPos = acce.slot[num2].addPos;
		acce.slot[num].addRot = acce.slot[num2].addRot;
		acce.slot[num].addScl = acce.slot[num2].addScl;
		acce.slot[num].addRot.x = Mathf.DeltaAngle(0f, acce.slot[num].addRot.x + 180f);
		this.human.accessories.UpdatePosition(acce, num);
		SystemSE.Play(SystemSE.SE.YES);
		this.Update_OtherUI();
	}

	// Token: 0x06000C35 RID: 3125 RVA: 0x00047390 File Offset: 0x00045590
	private void Update_OtherUI()
	{
		this.acceEdit.UpdateUI_NowTab();
		HWearAcceChangeUI hwearAcceChangeUI = UnityEngine.Object.FindObjectOfType<HWearAcceChangeUI>();
		if (hwearAcceChangeUI != null)
		{
			hwearAcceChangeUI.CheckShowUI();
		}
	}

	// Token: 0x04000C56 RID: 3158
	[SerializeField]
	private Toggle[] dstSlots = new Toggle[10];

	// Token: 0x04000C57 RID: 3159
	[SerializeField]
	private Toggle[] srcSlots = new Toggle[10];

	// Token: 0x04000C58 RID: 3160
	[SerializeField]
	private Toggle reverse;

	// Token: 0x04000C59 RID: 3161
	[SerializeField]
	private Button buttons_slotCopy;

	// Token: 0x04000C5A RID: 3162
	[SerializeField]
	private Button buttons_posCopy;

	// Token: 0x04000C5B RID: 3163
	[SerializeField]
	private Button buttons_posCopyRevH;

	// Token: 0x04000C5C RID: 3164
	[SerializeField]
	private Button buttons_posCopyRevV;

	// Token: 0x04000C5D RID: 3165
	[SerializeField]
	private AccessoryCustomEdit acceEdit;

	// Token: 0x04000C5E RID: 3166
	private Human human;
}
